import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// yarn add --dev @types/node
import path from 'path'



export default defineConfig({
  plugins: [react()],
  // 配置less
  css: {
    preprocessorOptions: {
      // yarn add less less-loader
      less: {
        // 配置全局变量
        additionalData: `@import "@/index.less";`,
        javascriptEnabled: true,
      },
    },
  },
  // 配置别名 tsconfig.json中也需要配置
  resolve: {
    alias: [
      {
        find: '@',
        replacement: path.resolve(__dirname, 'src')
      },
    ]
  },
  server: {
    hmr: true, // 开启热更新
    port: 9080,
    host: true,
    open: true,
    proxy: {
      '/prod-api': {
        target: 'http://rswq-admin.zhihuiplus.com',
        changeOrigin: true,
      },

    }
  },
})
